package com.logic.lhub.main.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.logic.lhub.R;
import com.logic.lhub.entity.MeetingHomeListEntity;
import com.logic.lhub.main.holder.IndexMeetingListHolder;
import com.qsmx.core.util.StringUtil;

import java.util.List;

public class IndexMeetingListAdapter extends RecyclerView.Adapter<IndexMeetingListHolder> {

    private Context mContext;

    private List<MeetingHomeListEntity.DataBean.ListBean> mData;

    public void setmData(List<MeetingHomeListEntity.DataBean.ListBean> data) {
        this.mData = data;
    }

    public IndexMeetingListAdapter(Context context) {
        this.mContext = context;
    }

    @NonNull
    @Override
    public IndexMeetingListHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new IndexMeetingListHolder(LayoutInflater.from(mContext).inflate(R.layout.adapter_meeting_list, parent, false));
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onBindViewHolder(@NonNull IndexMeetingListHolder holder, int position) {
        holder.tvMeetingTime.setText(StringUtil.getHourByTimestampLong(StringUtil.getStringToDateTimeNoT(mData.get(position).getReservationStartTime())) + "-" + StringUtil.getHourByTimestampLong(StringUtil.getStringToDateTimeNoT(mData.get(position).getReservationEndTime())));
        if (mData.get(position).getStatus().equals("1")) {
            holder.tvMeetingCompany.setText("会议中");
        } else if (mData.get(position).getStatus().equals("0")) {
            holder.tvMeetingCompany.setText("待开始");
        } else if (mData.get(position).getStatus().equals("2")) {
            holder.tvMeetingCompany.setText("已结束");
        } else if (mData.get(position).getStatus().equals("3")) {
            holder.tvMeetingCompany.setText("已取消");
        }

    }

    @Override
    public int getItemCount() {
        if (mData != null && mData.size() > 0) {
            return mData.size();
        } else {
            return 0;

        }
    }
}
